<?php
//部门
namespace app\crm\model;

use think\Db;

class Cusarea extends \ShopModel
{
    protected $table = 'sh_client_region';
    protected $pk = 'region_id';
    public function getallarea(){
    	return $this->select();
    }
    public function getlevel($pid){
    	$level=$this->where(["region_id"=>$pid])->value("level");
    	$level++;
    	return $level;
    }
    public function isrep($area_name){
    	$has=$this->where(["region_name"=>$area_name])->find();
    	return $has;
    }
    public function add($data){
    	return $this->insertGetId($data);
    }
    public function rename($id,$name){
    	return $this->where(["region_id"=>$id])->update(["region_name"=>$name]);
    }
    public function haschild($id){
    	return $this->where(["parent_id"=>$id])->find();
    }
    public function deletebyid($id){
    	return $this->where(["region_id"=>$id])->delete();
    }
}
